
package server;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;

import java.util.Collection;

public class AppConfig extends XMLConfiguration {

    private static AppConfig instance;
    private static String configFile = "wiichat-config.xml";

    // Singleton initialiser
    static {
        instance = new AppConfig(configFile);
    }

    /**
     * Constructor
     *
     * @param fileName Configuration file name.
     */
    private AppConfig(String fileName) {
        init(fileName);
    }

    /**
     * Initialize the class.
     *
     * @param fileName Configuration file name.
     */
    private void init(String fileName) {
        setFileName(fileName);
        try {
            load();
        } catch (ConfigurationException configEx) {
            configEx.printStackTrace();
        }
    }

    /**
     * Singleton access method.
     *
     * @return Singleton
     */
    public static AppConfig getInstance() {
        return instance;
    }

}


